package pers.lee.util.dev;

import java.util.StringTokenizer;

public class NameUtil {
	public static void main(String[] args) {
		
		String t1 = "merchantId,salesCountry,campaignPriority,enableLocal,purchasePlatform";
		formatUnderline(t1);
	}
	
	public static void formatUnderline(String text) {
		String[] textArr = text.split("[^0-9a-zA-Z]");
		for(String s:textArr) {
			formatUnderlineWord(s);
		}
	}
	public static void formatUnderlineWord(String text) {
		if(text != null && !text.equals("")) {
			char [] arr = text.toCharArray();
			StringBuffer sBuffer = new StringBuffer();
			for(int i=0;i<arr.length;i++) {
				char letter = arr[i];
				if(letter<97 && letter>64) {
					if(i != 0) {
						sBuffer.append("_");
					}
					char newChar = (char) (letter+32);
					sBuffer.append(newChar);
				}else {
					sBuffer.append(letter);
				}
			}
			System.out.println(sBuffer);
		}
	}
}
